let patt1 = new RegExp('hello')
let patt2 = /world/

// 使用
// test()正则检测
// let pat = /my/
// let str = 'this is my code...'

// let arr = str.split(' ')
// console.log(arr.indexOf('my'));

// console.log(pat.test(str));


// exec()正则检索
// let pat = /hello/
// let msg = 'oh my god'

// // console.log(pat.test(msg));
// console.log(pat.exec(msg));


// 正则表达式类型
// /pattern/attributes  g (全局匹配)  i (不区分大小写匹配)

// let str = 'Vist NanChang oh my world'
// let pat = /nanchang/i
// let pat = /nanchang/gi

// console.log(pat.test(str));
// console.log(pat2.test(str));


//search()
// let str = 'Vist W3School'
// let pat = /w3school/i
// console.log(str.search(pat));


//match()
// let str = '1 plus 2 equl 33'
// let pat = /\d+/g
// console.log(str.match(pat));


//replace()
// let str = 'Hello zj! oh I am wn'
// str.replace(/wn/,'snail')

